package com.macro.mall.initialize;//package com.macro.mall.initialize;
//import com.alibaba.cloud.commons.io.Charsets;
//import com.alibaba.nacos.shaded.com.google.common.io.CharStreams;
//import com.macro.mall.common.api.CommonResult;
//import com.macro.mall.common.dto.EsIndexDto;
//import com.macro.mall.remton.EsServiceRemton;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//
//@Component
//public class EsInitialize implements ApplicationRunner{
//    @Resource
//    private EsServiceRemton esServiceRemton;
//
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//        EsIndexDto esIndexDto = new EsIndexDto();
//        esIndexDto.setIndexName("logs");
//        InputStream mappings = EsInitialize.class.getClassLoader().getResourceAsStream("mappings.json");
//        InputStream settings = EsInitialize.class.getClassLoader().getResourceAsStream("settings.json");
//        String mappingsStr= CharStreams.toString(new InputStreamReader(mappings, Charsets.UTF_8));
//        String settingsStr= CharStreams.toString(new InputStreamReader(settings, Charsets.UTF_8));
//        esIndexDto.setIndexMappings(mappingsStr);
//        esIndexDto.setIndexSetting(settingsStr);
//        CommonResult commonResult = esServiceRemton.searchIndexChecker(esIndexDto.getIndexName());
//        Boolean data = (Boolean) commonResult.getData();
//        if (data==null){
//            esServiceRemton.createProductIndex(esIndexDto);
//        }
//
//
//    }
//}
